#ifndef _PILINK_FILEXFER_H_
#define _PILINK_FILEXFER_H_

#include "pilink_core.h"

#define PILINK_DATA_TYPE_FILE_INFO_REQUEST     (PILINK_CLASS_FILE + 0x01)
#define PILINK_DATA_TYPE_FILE_INFO             (PILINK_CLASS_FILE + 0x02)
#define PILINK_DATA_TYPE_FILE_SECTION_REQUEST  (PILINK_CLASS_FILE + 0x03)
#define PILINK_DATA_TYPE_FILE_SECTION          (PILINK_CLASS_FILE + 0x04)

#if PILINK_HANDLER_BUFFER_LENGTH > 32
    #define PILINK_FILE_SECTION_DATA_LEN            (PILINK_HANDLER_BUFFER_LENGTH - 16)
#else
    #error "PILINK_HANDLER_BUFFER_LENGTH must be larger than 32 byte"
#endif

#define PILINK_FILE_NAME_LEN            256

#pragma pack(1)

struct pilink_struct_file_info_request_s
{
    char           file_name[PILINK_FILE_NAME_LEN];
};

struct pilink_struct_file_info_s
{
    int            file_id;
    unsigned int   file_size;
    char           file_name[PILINK_FILE_NAME_LEN+1];
};

struct pilink_struct_file_section_request_s{
    short          file_id;
    unsigned short length;
    unsigned int   offset;
};

struct pilink_struct_file_section_s{
    unsigned int   file_id;
    unsigned int   offset;
    unsigned short length;
    unsigned char  data[PILINK_FILE_SECTION_DATA_LEN];
};

#pragma pack()


#endif
